package com.dongdongshop.servcice.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbSellerMapper;
import com.dongdongshop.pojo.TbSeller;
import com.dongdongshop.pojo.TbSellerExample;
import com.dongdongshop.service.SellerService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Service
@Component
public class SellerServiceImpl implements SellerService {
    @Resource
    private TbSellerMapper sellerMapper;

    @Override
    public void register(TbSeller seller) {

        sellerMapper.insertSelective(seller);
    }

    @Override
    public List<TbSeller> getSeller(String name,String nickName) {

        return sellerMapper.getSeller(name,nickName);
    }

    @Override
    public TbSeller getSellerById(String sellerId) {
        TbSeller tbSeller = sellerMapper.selectByPrimaryKey(sellerId);
        return tbSeller;
    }

    @Override
    public void approved(TbSeller seller) {
        seller.setStatus("1");
        sellerMapper.updateByPrimaryKeySelective(seller);
    }

    @Override
    public void auditfailed(TbSeller seller) {
        seller.setStatus("2");
        sellerMapper.updateByPrimaryKeySelective(seller);
    }

    @Override
    public void closeSeller(TbSeller seller) {
        seller.setStatus("3");
        sellerMapper.updateByPrimaryKeySelective(seller);
    }

    @Override
    public List<TbSeller> getAllSeller(String name, String nickName,String status) {
        return sellerMapper.getAllSeller(name,nickName,status);
    }

    @Override
    public TbSeller getInfoToLogin(String username) {
        TbSeller seller = sellerMapper.selectByPrimaryKey(username);
        return seller;
    }

    @Override
    public TbSeller pdSellerId(String sellerId) {
        return sellerMapper.selectByPrimaryKey(sellerId);
    }
}
